//
//  ZNewNotifyCollectionCell.m
//  WeClubs
//
//  Created by 花花 on 2017/6/26.
//  Copyright © 2017年 Zed. All rights reserved.
//

#import "ZNewNotifyCollectionCell.h"
#import <SDWebImage/UIImageView+WebCache.h>
@implementation ZNewNotifyCollectionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self initUI];
        [self initConstraints];
    }
    return self;
}

- (void)initUI{
    
    _imgView = [[UIImageView alloc]init];
    _imgView.backgroundColor =[UIColor orangeColor];
    _imgView.layer.cornerRadius = 45/2.0;
    _imgView.layer.masksToBounds = YES;
    [self addSubview:_imgView];
    
    
    
    
    _nameLabel = [[UILabel alloc]init];
    _nameLabel.backgroundColor =[UIColor yellowColor];
    _nameLabel.font = [UIFont systemFontOfSize:13];
    _nameLabel.text = @"";
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_nameLabel];


}

- (void)initConstraints{

    Z_WEAK_SELF;
     [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.width.height.mas_equalTo(45);
         make.left.right.mas_equalTo(0);
     }];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(weakSelf.imgView.mas_width);
        make.top.equalTo(weakSelf.imgView.mas_bottom).offset(5);
        make.height.mas_equalTo(15);
         make.left.equalTo(weakSelf.imgView.mas_left);
    }];
}


- (void)setModel:(ZStudentModel *)model{

    if (model == nil) return;
    
    _model  = model;
    
    self.nameLabel.text = model.name;
    
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:model.avatar_url] placeholderImage:defaultIcon];
    
    
        
    

}
@end
